#!/usr/bin/env python
'''
Created on Jan 21, 2011

@author: dexen
'''


from optparse import OptionParser

from dexen.system.common import service
from dexen.system.node import service as node_svc


def main():
    parser = OptionParser("node [OPTIONS]... ")
    parser.add_option("-i", "--server-ip", dest="reg_ip", metavar="SERVER_IP",
                      default=service.get_my_ip(), help="Connect to Server by ip address")
    parser.add_option("-n", "--server-name", dest="reg_name", metavar="SERVER_NAME",
                      default="dexen_server", help="Connect to Server by logical name")
    parser.add_option("-s", "--num-slaves", dest="n_slave_slots", metavar="NUM_SLAVES", 
                      type="int", default=4, help="Start with NUM_SLAVES")
    
    (options, args) = parser.parse_args()
    if len(args) > 0:
        parser.error("Incorrect number of arguments.")
    #print options.reg_ip, options.n_slave_slots    
    node_svc.start(options.reg_ip, options.reg_name, options.n_slave_slots, options.reg_name == "local")
    
if __name__ == "__main__":
    main()  